#include "los_swtmr.h"
#include "los_config.h"

#define AI_TASK_PERIOD_MS 100  // For example, execute once every 100ms

static VOID AITaskHandler(UINTPTR arg)
{
    // AI inference logic
    // The timer callback runs in interrupt context; do not perform time-consuming operations or printing
}

UINT32 HtfAISchedulerStart(VOID)
{
    UINT16 swtmrID = 0;
    UINT32 intervalTicks = LOS_MS2Tick(AI_TASK_PERIOD_MS); // Convert to system ticks

    UINT32 ret = LOS_SwtmrCreate(
        intervalTicks,
        LOS_SWTMR_MODE_PERIOD,   // Execute periodically
        (SWTMR_PROC_FUNC)AITaskHandler,
        &swtmrID,
        0                        // arg
    );

    if (ret != LOS_OK) {
        return ret;
    }

    return LOS_SwtmrStart(swtmrID);
}